$def with (page, edition=None, edit=True)

$if page.type.key in ["/type/work", "/type/edition", "/type/author"]:
    $if edition and page.type.key in ["/type/work"]:
        $ edit_url = edition.url(suffix="/edit")
        $ edit_url += '?work_key=%s' % page.key
    $else:
        $ edit_url = page.url(suffix="/edit")
$else:
    $ edit_url = page.key + "?m=edit"

<div id="editTools" class="edit">
    <div id="editInfo">
        $if "superfast" in ctx.features:
            $ author = page.get_most_recent_change().author
        $else:
            $ author = get_recent_author(page)
        $if author:
            <div class="brown smaller sansserif">$:_('Last edited by %(author_link)s', author_link=author.render_link())</div>
        $else:
            <div class="brown smaller sansserif">$_("Last edited anonymously")</div>
        $if page.url:
            <div class="smallest gray sansserif">$(page.last_modified and datestr(page.last_modified)) | <a href="$page.url(m='history')" rel="nofollow" title="$_('View this template\'s edit history')">$_('History')</a></div>
        $else:
            <div class="smallest gray sansserif">$(page.last_modified and datestr(page.last_modified)) | <a href="$changequery(m='history')" rel="nofollow" title="$_('View this template\'s edit history')">$_('History')</a></div>
    </div>
    $if edit and not page.is_fake_record():
        <div class="editButton">
          <!-- FIXME: accesskey / keyboard shortcut needs i18n -->
          <a
            class="cta-btn cta-btn--vanilla"
            href="$edit_url"
            title="$_('Edit this page')"
            data-ol-link-track="CTAClick|Edit"
            accesskey="e"
            rel="nofollow"
        >$_("Edit")</a>
        </div>
</div>
